const oneDay =  24 * 60 * 60 * 1000;
export class Utils {
    constructor() {

    }
    transferUTCToLocal(UTC){
        let delay = new Date(UTC).toJSON()
        let resp = new Date(
            +new Date(delay) + 8 * 3600 * 1000
        ).toISOString()
            .replace(/T/g, " ")
            .replace(/\.[\d]{3}Z/, "");
        return resp;
    }
    countDown(time) {
        let nowTime = +new Date(); // 返回的是当前时间总的毫秒数
        let inputTime = +new Date(time); // 返回的是用户输入时间总的毫秒数
        let times = (inputTime - nowTime) / 1000; // times是剩余时间总的秒数
        let d = parseInt(times / 60 / 60 / 24); // 天
        d = d < 10 ? '0' + d : d;
        let h = parseInt(times / 60 / 60 % 24); //时
        h = h < 10 ? '0' + h : h;
        let m = parseInt(times / 60 % 60); // 分
        m = m < 10 ? '0' + m : m;
        let s = parseInt(times % 60); // 当前的秒
        s = s < 10 ? '0' + s : s;
        let str = ""
        if(d !== "00") str += d + '天'
        if(h !== "00") str += h + '时'
        str +=  m + '分' + s + '秒'
        return str;
    }
}